.class public Lcom/burstly/lib/network/request/ImageFetchTask;
.super Lcom/burstly/lib/network/request/SafeAsyncTask;
.source "ImageFetchTask.java"


# annotations
.annotation system Ldalvik/annotation/Signature;
    value = {
        "Lcom/burstly/lib/network/request/SafeAsyncTask",
        "<",
        "Landroid/graphics/Bitmap;",
        ">;"
    }
.end annotation


# static fields
.field private static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field private static final TAG:Ljava/lang/String; = "ImageFetchTask"


# instance fields
.field private mCache:Lcom/burstly/lib/persistance/IResourse;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lcom/burstly/lib/persistance/IResourse",
            "<",
            "Landroid/graphics/Bitmap;",
            ">;"
        }
    .end annotation
.end field

.field private final mCallback:Lcom/burstly/lib/network/request/IRequestCallback;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lcom/burstly/lib/network/request/IRequestCallback",
            "<",
            "Landroid/graphics/Bitmap;",
            ">;"
        }
    .end annotation
.end field

.field private final mDebugger:Lcom/burstly/lib/util/Utils$DebugWrapper;

.field private mScale:F


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 33
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/network/request/ImageFetchTask;->LOG:Lcom/burstly/lib/util/LoggerExt;

    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Lcom/burstly/lib/network/request/IRequestCallback;)V
    .locals 1
    .parameter "imageUrl"
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            "Lcom/burstly/lib/network/request/IRequestCallback",
            "<",
            "Landroid/graphics/Bitmap;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 130
    .local p2, callback:Lcom/burstly/lib/network/request/IRequestCallback;,"Lcom/burstly/lib/network/request/IRequestCallback<Landroid/graphics/Bitmap;>;"
    invoke-direct {p0}, Lcom/burstly/lib/network/request/SafeAsyncTask;-><init>()V

    .line 53
    const/high16 v0, 0x3f80

    iput v0, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mScale:F

    .line 131
    invoke-virtual {p0, p1}, Lcom/burstly/lib/network/request/ImageFetchTask;->setHost(Ljava/lang/String;)V

    .line 132
    iput-object p2, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mCallback:Lcom/burstly/lib/network/request/IRequestCallback;

    .line 133
    const-string v0, "ImageFetchTask"

    invoke-static {v0}, Lcom/burstly/lib/util/Utils$DebugWrapper;->getDebugger(Ljava/lang/String;)Lcom/burstly/lib/util/Utils$DebugWrapper;

    move-result-object v0

    iput-object v0, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mDebugger:Lcom/burstly/lib/util/Utils$DebugWrapper;

    .line 134
    return-void
.end method

.method private scaleImage(Landroid/graphics/Bitmap;)Landroid/graphics/Bitmap;
    .locals 4
    .parameter "image"

    .prologue
    .line 100
    if-nez p1, :cond_0

    .line 101
    const/4 v2, 0x0

    .line 105
    :goto_0
    return-object v2

    .line 103
    :cond_0
    iget v2, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mScale:F

    invoke-virtual {p1}, Landroid/graphics/Bitmap;->getWidth()I

    move-result v3

    int-to-float v3, v3

    mul-float/2addr v2, v3

    float-to-int v1, v2

    .line 104
    .local v1, scaledWidth:I
    iget v2, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mScale:F

    invoke-virtual {p1}, Landroid/graphics/Bitmap;->getHeight()I

    move-result v3

    int-to-float v3, v3

    mul-float/2addr v2, v3

    float-to-int v0, v2

    .line 105
    .local v0, scaledHeight:I
    const/4 v2, 0x1

    invoke-static {p1, v1, v0, v2}, Landroid/graphics/Bitmap;->createScaledBitmap(Landroid/graphics/Bitmap;IIZ)Landroid/graphics/Bitmap;

    move-result-object v2

    goto :goto_0
.end method


# virtual methods
.method public getScale()F
    .locals 1

    .prologue
    .line 149
    iget v0, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mScale:F

    return v0
.end method

.method protected onPostExecute(Landroid/graphics/Bitmap;)V
    .locals 4
    .parameter "result"

    .prologue
    .line 110
    invoke-super {p0, p1}, Lcom/burstly/lib/network/request/SafeAsyncTask;->onPostExecute(Ljava/lang/Object;)V

    .line 111
    sget-boolean v0, Lcom/burstly/lib/constants/Constants;->IS_DEBUG_MODE:Z

    if-eqz v0, :cond_0

    .line 112
    sget-object v0, Lcom/burstly/lib/network/request/ImageFetchTask;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "ImageFetchTask"

    const-string v2, "Memory state after loading image:"

    const/4 v3, 0x0

    new-array v3, v3, [Ljava/lang/Object;

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 113
    iget-object v0, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mDebugger:Lcom/burstly/lib/util/Utils$DebugWrapper;

    invoke-virtual {v0}, Lcom/burstly/lib/util/Utils$DebugWrapper;->logAll()V

    .line 115
    :cond_0
    iget-object v0, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mCallback:Lcom/burstly/lib/network/request/IRequestCallback;

    if-eqz v0, :cond_1

    .line 116
    if-eqz p1, :cond_2

    .line 117
    iget-object v0, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mCallback:Lcom/burstly/lib/network/request/IRequestCallback;

    invoke-interface {v0, p1}, Lcom/burstly/lib/network/request/IRequestCallback;->onSuccessUi(Ljava/lang/Object;)V

    .line 122
    :cond_1
    :goto_0
    return-void

    .line 119
    :cond_2
    iget-object v0, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mCallback:Lcom/burstly/lib/network/request/IRequestCallback;

    const/4 v1, 0x0

    invoke-interface {v0, v1}, Lcom/burstly/lib/network/request/IRequestCallback;->onFailUi(Ljava/lang/Object;)V

    goto :goto_0
.end method

.method protected bridge synthetic onPostExecute(Ljava/lang/Object;)V
    .locals 0
    .parameter "x0"

    .prologue
    .line 29
    check-cast p1, Landroid/graphics/Bitmap;

    .end local p1
    invoke-virtual {p0, p1}, Lcom/burstly/lib/network/request/ImageFetchTask;->onPostExecute(Landroid/graphics/Bitmap;)V

    return-void
.end method

.method protected performInBackground()Landroid/graphics/Bitmap;
    .locals 4

    .prologue
    .line 79
    invoke-super {p0}, Lcom/burstly/lib/network/request/SafeAsyncTask;->performInBackground()Ljava/lang/Object;

    .line 80
    invoke-static {}, Lcom/burstly/lib/network/request/RequestManager;->isOnline()Z

    move-result v0

    if-nez v0, :cond_0

    .line 81
    const/4 v0, 0x0

    .line 90
    :goto_0
    return-object v0

    .line 83
    :cond_0
    sget-boolean v0, Lcom/burstly/lib/constants/Constants;->IS_DEBUG_MODE:Z

    if-eqz v0, :cond_1

    .line 84
    sget-object v0, Lcom/burstly/lib/network/request/ImageFetchTask;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "ImageFetchTask"

    const-string v2, "Memory state before loading image:"

    const/4 v3, 0x0

    new-array v3, v3, [Ljava/lang/Object;

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 85
    iget-object v0, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mDebugger:Lcom/burstly/lib/util/Utils$DebugWrapper;

    invoke-virtual {v0}, Lcom/burstly/lib/util/Utils$DebugWrapper;->logAll()V

    .line 87
    :cond_1
    iget-object v0, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mCache:Lcom/burstly/lib/persistance/IResourse;

    if-eqz v0, :cond_2

    .line 88
    iget-object v0, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mCache:Lcom/burstly/lib/persistance/IResourse;

    invoke-virtual {p0}, Lcom/burstly/lib/network/request/ImageFetchTask;->getHost()Ljava/lang/String;

    move-result-object v1

    invoke-interface {v0, v1}, Lcom/burstly/lib/persistance/IResourse;->getResource(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/graphics/Bitmap;

    invoke-direct {p0, v0}, Lcom/burstly/lib/network/request/ImageFetchTask;->scaleImage(Landroid/graphics/Bitmap;)Landroid/graphics/Bitmap;

    move-result-object v0

    goto :goto_0

    .line 90
    :cond_2
    invoke-virtual {p0}, Lcom/burstly/lib/network/request/ImageFetchTask;->getHost()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/burstly/lib/util/Utils;->getBitmapByUrl(Ljava/lang/String;)Landroid/graphics/Bitmap;

    move-result-object v0

    invoke-direct {p0, v0}, Lcom/burstly/lib/network/request/ImageFetchTask;->scaleImage(Landroid/graphics/Bitmap;)Landroid/graphics/Bitmap;

    move-result-object v0

    goto :goto_0
.end method

.method protected bridge synthetic performInBackground()Ljava/lang/Object;
    .locals 1

    .prologue
    .line 29
    invoke-virtual {p0}, Lcom/burstly/lib/network/request/ImageFetchTask;->performInBackground()Landroid/graphics/Bitmap;

    move-result-object v0

    return-object v0
.end method

.method public setCache(Lcom/burstly/lib/persistance/IResourse;)V
    .locals 0
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lcom/burstly/lib/persistance/IResourse",
            "<",
            "Landroid/graphics/Bitmap;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 140
    .local p1, cache:Lcom/burstly/lib/persistance/IResourse;,"Lcom/burstly/lib/persistance/IResourse<Landroid/graphics/Bitmap;>;"
    iput-object p1, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mCache:Lcom/burstly/lib/persistance/IResourse;

    .line 141
    return-void
.end method

.method public setScale(F)V
    .locals 0
    .parameter "scale"

    .prologue
    .line 158
    iput p1, p0, Lcom/burstly/lib/network/request/ImageFetchTask;->mScale:F

    .line 159
    return-void
.end method
